import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import { defineConfig } from 'eslint/config'


export default defineConfig([
  { files: ['**/*.{js,mjs,cjs,ts,vue}'], plugins: { js }, extends: ['js/recommended'] },
  { files: ['**/*.{js,mjs,cjs,ts,vue}'], languageOptions: { globals: {...globals.browser, ...globals.node} } },
  tseslint.configs.recommended,
  pluginVue.configs['flat/essential'],
  { files: ['**/*.vue'], languageOptions: { parserOptions: { parser: tseslint.parser } } },
  {
    rules: {
      'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }], //必须使用单引号，禁止使用双引号
      'semi': ['error', 'never'], // 行末必须有分号
      'indent': ['error', 2],
      'comma-dangle': ['error', 'never'], // 多行时强制末尾逗号
      'space-before-function-paren': ['error', 'never'], // 函数括号前无空格
      'vue/no-multiple-template-root': 'off', // 模板存在多个根节点
      'vue/multi-word-component-names': 'off' // 文件名单个字母
    }
  }
])